#include<iostream>
using namespace std;
const int N=1e2+10;
int p[N];
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		for(int i=1;i<=n;i++)
		cin>>p[i];
		int i=1,j=n;
		while(i+1<=n&&p[i+1])
		i++;
		while((j-1)&&p[j-1])
		j--;
		if(j<=i)
		cout<<'0'<<endl;
		else
		cout<<j-i<<endl;
	}
	return 0;
}
